---
title: Slack
---

## Prerequisites

The following example requires the `slack-sdk` library.

```shell
pip install openai slack-sdk
```

Get a Slack token from [here](https://api.slack.com/tutorials/tracks/getting-a-token).

```shell
export SLACK_TOKEN=***
```

## Example

The following agent will use Slack to send a message to a channel, list all channels, and get the message history of a specific channel.

```python cookbook/tools/slack_tools.py
import os

from agno.agent import Agent
from agno.tools.slack import SlackTools

slack_tools = SlackTools()

agent = Agent(tools=[slack_tools])

# Example 1: Send a message to a Slack channel
agent.print_response("Send a message 'Hello from Agno!' to the channel #general", markdown=True)

# Example 2: List all channels in the Slack workspace
agent.print_response("List all channels in our Slack workspace", markdown=True)

# Example 3: Get the message history of a specific channel by channel ID
agent.print_response("Get the last 10 messages from the channel 1231241", markdown=True)

```

## Toolkit Params

| Parameter                       | Type   | Default | Description                                                         |
| ------------------------------- | ------ | ------- | ------------------------------------------------------------------- |
| `token`                         | `str`  | `None`  | Slack API token for authentication                                 |
| `enable_send_message`           | `bool` | `True`  | Enables functionality to send messages to Slack channels           |
| `enable_send_message_thread`    | `bool` | `True`  | Enables functionality to send threaded messages                    |
| `enable_list_channels`          | `bool` | `True`  | Enables functionality to list available Slack channels             |
| `enable_get_channel_history`    | `bool` | `True`  | Enables functionality to retrieve message history from channels    |
| `all`                           | `bool` | `False` | Enables all functionality when set to True                         |

## Toolkit Functions

| Function              | Description                                         |
| --------------------- | --------------------------------------------------- |
| `send_message`        | Sends a message to a specified Slack channel        |
| `list_channels`       | Lists all available channels in the Slack workspace |
| `get_channel_history` | Retrieves message history from a specified channel  |

## Developer Resources

- View [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/slack.py)
- View [Cookbook](https://github.com/agno-agi/agno/tree/main/cookbook/tools/slack_tools.py)
